<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

 <jsp:include page="../header.jsp"></jsp:include>
<c:if test="${project==null }">
   <jsp:forward page="../project.do?action=query1"></jsp:forward>
</c:if>

<fieldset class="layui-elem-field layui-field-title">
  <legend>修改项目</legend> 
</fieldset>
<form action="edit" method="post"  class="layui-form">

	<div class="layui-form-item">
		<label class="layui-form-label">项目名字</label>
		<div class="layui-input-inline">
			<input type="text" name ="pname"  value="${project.name }" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">开始时间</label>
		<div class="layui-input-inline">
			<input type="text" name="pstart" value="<fmt:formatDate value="${project.start}" pattern="yyyy-MM-dd"/>" class="layui-input"/>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">结束时间</label>
		<div class="layui-input-inline">
			<input type="text" name="pend" value="<fmt:formatDate value="${project.end }" pattern="yyyy-MM-dd"/>"  class="layui-input"/>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">项目奖金</label>
		<div class="layui-input-inline">
			<input type="text" name ="pbonus" value="${project.bonus}" class="layui-input">
		</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label">相关人员</label>
		<div class="layui-input-block" id="staff_list">
			
			
		</div>
	</div>
	
	<div class="layui-form-item">
		<label class="layui-form-label"></label>
		<div class="layui-input-inline">
			<input type ="submit" value="修改"  class="layui-btn layui-btn-primary layui-border-blue">
		</div>
		<div class="layui-form-mid layui-word-aux">${error}</div>
	</div>


</form>

<script type="text/javascript" src="js/jquery-2.1.4.js"></script>
<script type="text/javascript">
layui.use(['laydate','form'], function(){
var form = layui.form;
var laydate =layui.laydate;
//渲染事件日期控件
laydate.render({
   elem: 'input[name="pstart"]',
});
laydate.render({
    elem: 'input[name="pend"]',//指定元素
	});
$.ajax({
		url:'staff.do',
		type:'post',
		data:{action:"getAll"},
		dataType:'json',
		success:function (data){
			var html="";
           $.each(data,function (index,item){
			html +='<input type="checkbox" name="staff_id" value="'+ item.id+'" title="'+item.name+'"  lay-skin="primary">' 
          
           });
           $("#staff_list").html(html)
           //渲染
			form.render();
           // 再获取当前项目所有的员工
           $.ajax({
			url:'project.do',
			type:'post',
			data:{action:'getStaffByProjectId',project_id:${project.id}},
			dataType: 'json',
			success:function (data){
				//遍历所有员工id
				$.each(data,function (index,item){
					$("input[value='"+item.staff_id+"']").attr("checked","checked");
				})
                   //渲染
                   form.render();
               },
               error:function (){
               }
           });
       },
       error:function (){
       }
   })
});
</script>

 <jsp:include page="../footer.jsp"></jsp:include>
